<?xml version="1.0" encoding="UTF-8"?>
<!--
  Created by IntelliJ IDEA.
  User: Nikita.Brazhnikov
  Date: 5/31/13
  Time: 12:59 PM
-->
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:o="http://omnifaces.org/ui">
<h:head>
    <title>Edit</title>
    <h:outputStylesheet library="primefaces-extensions-uncompressed" name="codemirror/mode/tiki.css"/>
    <o:importFunctions type="ru.bragnikita.utils.logexplorer.web.ConvertationUtils" var="cu"/>
</h:head>

<h:body>
    <f:decorate template="WEB-INF/templates/template.xhtml">
        <c:metadata>
            <c:viewParam name="file" value="#{file_edit.filePath}"/>
            <c:event type="preRenderView" listener="#{file_edit.reload()}"/>
        </c:metadata>
        <h:form id="file_edit_form">
            <p:panel id="control_panel">
                <h:inputHidden id="hid_filepath" value="#{file_edit.filePath}"/>
                <p:messages redisplay="true" id="msgs"/>
                <p:panelGrid columns="3">
                    #{file_edit.fileName}
                    <p:selectOneMenu value="#{file_edit.encoding}" id="combo_encoding">
                        <c:selectItems value="#{cu:getAvailableCharsets()}"/>
                        <p:ajax event="change" process="control_panel" update="edit_panel,control_panel" listener="#{file_edit.reload}"/>
                    </p:selectOneMenu>
                    <p:commandButton id="btn_save" action="#{file_edit.save}" process="@(form)" value="Save" update="control_panel"/>
                </p:panelGrid>
            </p:panel>
            <p:panel id="edit_panel">
                <pe:codeMirror value="#{file_edit.textContent}" theme="eclipse" mode="#{file_edit.textMode}" lineNumbers="true"/>
            </p:panel>
            <p:blockUI id="table_blocker" trigger="combo_encoding, btn_save" block="edit_panel">
                <p:graphicImage value="#{resource['images:icon_waiting.gif']}"/>
            </p:blockUI>
            <p:blockUI id="save_blocker" trigger="btn_save" block="btn_save"/>
        </h:form>
    </f:decorate>
</h:body>

</html>